<%@ page language="java" import="java.util.*,pojo.*,service.*,base.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>用户评论</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
    <style type="text/css"> 
    </style>
<script type="text/javascript" src="../jquery/jquery-1.6.1.js"></script>
<script type="text/javascript">
</script>
  </head>
  <body >
  <div class="navbar navbar-inverse navbar-fixed-top">
       <div class="navbar-inner">
           <div class="container-fluid">
              <a class="brand" href="index.jsp">白金汉宫网上订餐</a>
                    <div class="nav-collapse collapse">
                      <ul class="nav">
                        <li class="active">
                          <a href="index.jsp">主页</a>
                     </li>

                       </ul>
                             <p class="navbar-text pull-right">
    <%
        
		String username = (String)session.getAttribute( "name" );
		CartService cs= new CartService();
		if ( username == null || username == "" )
		{
	%>
<a class="navbar-link" href="login.jsp">登录</a>&nbsp;&nbsp;&nbsp;<a class="navbar-link" href="regest.jsp">注册</a>
    <%
} 
	else
	{
		int userid=(Integer)session.getAttribute("id");
		int cartNum=cs.getALL(userid);
			out.println( "欢迎您! "+username  );
			out.println("<a href='memberzone.jsp' role='button' class='btn btn-success' >个人中心</a>");
			out.println("<a href='cartlist.jsp' data-placement='bottom' role='button' class='btn btn-warning' data-toggle='tooltip' title='ffff'>我的购物车"+cartNum+"</a>");
			out.println( "<a href='destroySession.jsp' role='button' class='btn btn-danger' >安全退出</a>" );
	}
     %>
</p>
	                 </div>   
                 </div>
             </div>
         </div>
  <div class="container">
        <div class="row">
    <div class="span9">
          <p class="text-info" style="font-weight:bold;font-size:30px;">用户评论</p>
    <%
 request.setCharacterEncoding("utf-8");
	ReviewService rs=new ReviewService();
    String where=" where 1=1";         
	
    int size=rs.getALL(where);
    String spageno = request.getParameter("pageno");
    int pageno;//页码
    int pagesize=7;//每页显示行数
    if(spageno==null){ pageno = 1;}//当页码为空时默认为1
    else pageno=Integer.parseInt(request.getParameter("pageno"));//否则为传过来的页码
	try{pageno = Integer.parseInt(spageno);}
	catch(Exception e){}
	Page p1=new Page();
								p1.setTotalRecord(size);
								p1.setCurrentPageNo(pageno);
								p1.setPageSize(pagesize);	
	List<review> reviewlist = rs.getReview(pageno,pagesize,where);//按参数查询	
  %> 
  <table class="table table-hover">
      <tr>
        <td >评论时间</td>
        <td >用户名</td>
        <td >评价等级</td>
        <td >评价内容</td>
      </tr>
  <%
  for (review re : reviewlist) {
	out.println("<input type='hidden' name='id' value='"+re.getId()+"'>");
	out.println("<tr><td>"+re.getTime()+"</td>");
    MemberService ms=new MemberService();
    out.println("<td>"+ms.getInfo(re.getUserid()).getUsername()+"</td>");
    int s=re.getLevel();
    if(s==1){
    out.println("<td>好评</td>");
    }
    else if(s==2){
    out.println("<td>中评</td>");
    }
    else out.println("<td>差评</td>");
	
	out.println("<td><div align='center'>"+re.getContent()+"</div></td></tr>");
	
	
	}
	
	out.println("<tr><td colspan='9'><h5>共"+p1.getTotalPage()+"页，当前第"+pageno+"页， ---<a href='reviewRecord.jsp?&pageno="+p1.getPrePage()+"'>上一页</a>");
								 out.print("<a href='reviewRecord.jsp?&pageno="+p1.getNextPage()+"'>下一页</a></h5></td></tr>");
%>
  
  
  
    
      </table>
    </div>
    </div>
    </div>
    <script src="../bootstrap/js/bootstrap.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
  </body>
</html>
